package cn.acewill.wsh.dagger2framedemolearn.feature

import android.app.Application
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import cn.acewill.wsh.dagger2framedemolearn.R
import cn.acewill.wsh.dagger2framedemolearn.app.DaggerApp
import cn.acewill.wsh.dagger2framedemolearn.feature.di.DaggerMainActivityComponet
import cn.acewill.wsh.dagger2framedemolearn.feature.di.MainActivityModule
import com.orhanobut.logger.Logger
import kotlinx.android.synthetic.main.activity_main.*
import javax.inject.Inject

class MainActivity : AppCompatActivity() {

    @Inject
    lateinit var student: Student

    @Inject
    lateinit var sharedPreferences: SharedPreferences

    @Inject
    lateinit var application: DaggerApp

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        DaggerMainActivityComponet.builder()
            .mainActivityModule(MainActivityModule(this))
            .appComponent(DaggerApp.appComponent)
            .build()
            .inject(this)

        btn_student.setOnClickListener {
            Logger.d(student.toString())
            Logger.d(sharedPreferences)
            Logger.d(application)
        }
    }
}
